/*
 * @Author: 一盏青灯欲锁魂
 * @Date: 2021-06-15 16:35:58
 * @LastEditTime: 2021-06-25 09:02:28
 * @Description: 数据库操作层
 * @FilePath: \nest_demo\src\module\index\index.service.ts
 */
import { Injectable } from '@nestjs/common';
import { Repository, Connection, getRepository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { UserEntity } from './user.entity';



@Injectable()
export class UserService{
    constructor(
        @InjectRepository(UserEntity)
        private readonly usersRepository:Repository<UserEntity>,
        private connection:Connection,
    ){};

    // 查询数据库是异步，所以这里需要做同步处理
    async getDocument():Promise<UserEntity[]>{
        return await this.usersRepository.find();
    }
}